const app = getApp();
Page({
  data: {
    exelist: [],
    // 当前步骤
    currentStep: 2,
    id: "",
    exusername: "",
    timelineItems: [],
    avatarImg: app.getImgUrl('contract.webp'),
    b1Img: app.getImgUrl('b1.png'),
    b2Img: app.getImgUrl('b2.png'),
    repairIcon: app.getImgUrl('repair-icon.png'),
    placeholderImg: app.getImgUrl('placeholder.png'),
  },
  async getdetail() {
    let res = await app.axios(
      'workOrder',
      {
        op: "ajaxWorkOrderDetail",
        id: this.data.id
      },
      false
    )
    this.setData({
      exelist: res.item.exelist.map(items => {
        items.timename = this.formatTimestamp(items.addtime)

        const systemInfo = wx.getSystemInfoSync();

        return items
      })
    })
  },
  formatTimestamp(timestamp) {
    const date = new Date(timestamp * 1000); // 秒级时间戳转毫秒级

    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');

    return `${year}年${month}月${day}日 ${hours}:${minutes}`;
  },
  onBack() {
    wx.navigateBack();
  },
  onLoad(options) {
    console.log(options.exusername)
    this.setData({
      id: options.id,
      exusername: options.exusername
    })
    this.getdetail()
  },
  /**
   * 个人名片
   */
  onEngineerCardTap() {
    wx.navigateTo({
      url: "/pages/client/personal_card",
    });
  },

  /**
   * 点击结束
   */
  onFinishBtnTap() {
    console.log("点击完结");
  },

  /**
   * 点击支付按钮
   */
  onPayBtnTap() {
    console.log("点击支付按钮");
  },
});
